package com.qianniu.napi.admin.service.akka;

import akka.actor.UntypedActor;
import com.qianniu.napi.common.util.WeixinUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by chenxuebin on 2017/7/31.
 */
public class NotifyActor extends UntypedActor {

    private final static Logger logger = LoggerFactory.getLogger(NotifyActor.class);

    @Override
    public void onReceive(Object message) {

        String msg = message.toString();
        logger.debug(">>>>>> NotifyActor receive message:" + msg);

        // 格式 type+uid+toke
        String[] arr = msg.split("@");
        if (arr.length < 3) return;
        String type = arr[0];
        String uid = arr[1];
        String mediaId = arr[2];
        String wxType = arr[3];
//        Long wxType = null;
//        try {
//            wxType = Long.valueOf(arr[3]);
//        } catch (Exception e) {
//            logger.error("======NotifyActor to Long error",e);
//        }

        WeixinUtil.sendCustomMsg(uid, type, mediaId, wxType);
        logger.debug(">>>>>> NotifyActor over for uid:" + uid + " media_type=" + type);
    }


}
